<template>
	<view class="container-nav">
		<view class="nav-body">
			<view class="w-box">
				<view class="w-box-row">
					<view class="row-later-title">
						<view class="later-title-dot">*</view>
						<view>业务类型</view>
					</view>
					<view class="row-later-time">
						<picker @change="onPickerChange" :value="lt_arr[lt_index].BusinessCode" :range="lt_arr" :range-key="'BusinessName'">
							{{lt_arr[lt_index].BusinessName}}
						</picker>
					</view>
				</view>
			</view>
			<view class="w-box">
				<view class="w-box-row">
					<view class="row-later-title">
						<view class="later-title-dot">*</view>
						<view>发起人</view>
					</view>
					<view class="row-later-time" @click="onSelTaskSearchUser">
						<text>{{TaskCreateUserName}}</text>
					</view>
				</view>
			</view>
			<view class="w-box">
				<view class="w-box-row">
					<view class="row-later-title">
						<view class="later-title-dot">*</view>
						<view>创建时间</view>
					</view>
					<view class="row-later-time" @click="onSelDatePicker(0)">
						{{Createtime}}
					</view>
				</view>
			</view>
			<view class="w-box">
				<view class="w-box-row">
					<view class="row-later-title">
						<view class="later-title-dot">*</view>
						<view>更新时间</view>
					</view>
					<view class="row-later-time" @click="onSelDatePicker(1)">
						{{Updatetime}}
					</view>
				</view>
			</view>
			<view class="w-btns">
				<button type="primary" @click="onSearchTodoList">确定</button>
			</view>
		</view>
		<date-time-picker ref='date-time' :endYear="endYear" type='datetime-all' @change='onDateTimeChange'></date-time-picker>
	</view>
</template>

<script>
	let pageApp = getApp();
	import DateTimePicker from '@/components/uni-dateTimePicker/uni-dateTimePicker.vue'
	export default {
		data() {
			return {
				endYear: 2030,
				lt_arr: [],
				lt_index: 0,
				Createtime: "请选择",
				TaskCreateUser: 0,
				TaskCreateUserName: "请选择",
				Updatetime: "请选择",
				StartOrEnd: 0
			}
		},
		components: {
			DateTimePicker
		},
		onShow: function() {
			uni.$on("seletedUser", (d) => {
				this.TaskCreateUser = d.UserID;
				this.TaskCreateUserName = d.UserName;
			})
		},
		onLoad: function() {
			this.getTodoList();
			this.lt_arr = JSON.parse(uni.getStorageSync("BusinessList"));
		},
		methods: {
			onPickerChange(e) {
				this.lt_index = e.target.value;
			},
			onSelDatePicker(index) {
				this.StartOrEnd = index;
				this.$refs['date-time'].show();
			},
			onDateTimeChange(value) {
				if (this.StartOrEnd) {
					this.Updatetime = value;
				} else {
					this.Createtime = value;
				}
			},
			onSelTaskSearchUser() {
				uni.navigateTo({
					url: '../../home/msg/MsgSearchUser?source=todo'
				})
			},
			getTodoList() {
				if (!uni.getStorageSync("BusinessList")) {
					// 准备数据
					let apiData = {
						url: pageApp.globalData.url + "/BusinessList",
						data: {
							"row": 10,
							"page": 1
						},
						success: (d) => {
							if (d.data.code == "001") {
								uni.setStorageSync("BusinessList", JSON.stringify(d.data.data.items));
							}
						}
					}
					// 发送数据
					this.vjAjaxData(apiData);
				}
			},
			onSearchTodoList() {
				// 获取传递的值
				let param_todolist = {};
				if (this.TaskCreateUser != 0) {
					param_todolist.TaskCreateUser = this.TaskCreateUser;
				}
				if (this.Createtime != '请选择') {
					param_todolist.Createtime = this.Createtime;
				}
				if (this.Updatetime != '请选择') {
					param_todolist.Updatetime = this.Updatetime;
				}
				if (this.lt_arr[this.lt_index]!='活动') {
					param_todolist.BusinessName = this.lt_arr[this.lt_index].BusinessName;
				}
				uni.$emit('seletedTodoList', param_todolist)
				uni.navigateBack({
					delta: 1
				});
			}
		}
	}
</script>

<style>
	page {
		background-color: #F1F5F6;
	}

	.container-nav {
		font-size: 14px;
		line-height: 24px;
	}

	.ql-container {
		height: 100rpx;
		min-height: 100rpx;
	}

	.w-nav {
		display: flex;
		justify-content: space-between;
		margin-bottom: 20rpx;
		background-color: #FFFFFF;
		padding: 20rpx 0;
	}

	.nav-focus {
		border-bottom: solid 6rpx #4497e1;
		padding-bottom: 20rpx;
	}

	.nav-title {
		width: 50%;
		text-align: center;
	}

	.nav-tip {
		position: relative;
		padding: 10rpx;
		display: flex;
		width: 100%;
		top: -30rpx;
		background-color: #4497e1;
		color: #ffffff;
		font-size: 26rpx;
		justify-content: space-around;
	}

	.w-box {
		margin: 20rpx 0;
		padding: 40rpx;
		background-color: #ffffff;
		position: relative;

	}

	.w-box .pass {
		border: solid 6rpx #a7e3cf;
		position: absolute;
		right: 0;
		bottom: 0;
		width: 140rpx;
		height: 140rpx;
		text-align: center;
		line-height: 140rpx;
		border-radius: 50%;
		color: #a7e3cf;
		font-weight: 700;
		transform: rotateZ(-30deg);
	}

	.w-box .refuse {
		border: solid 6rpx #f2bbb7;
		position: absolute;
		right: 0;
		bottom: 0;
		width: 140rpx;
		height: 140rpx;
		text-align: center;
		line-height: 140rpx;
		border-radius: 50%;
		color: #f2bbb7;
		font-weight: 700;
		transform: rotateZ(-30deg);
	}

	.row-later-title {
		display: flex;
		font-size: 34rpx;
	}

	.later-title-dot {
		padding: 8rpx;
		color: #FFFFFF;
	}

	.row-later-time {
		margin-left: 30rpx;
	}

	.w-box-title {
		display: flex;
		position: relative;
	}

	.w-box-title-img {
		width: 60rpx;
		height: 60rpx;
		padding: 4rpx;
		text-align: center;
		line-height: 60rpx;
		border-radius: 16rpx;
		background-color: #4497e1;
		margin-right: 16rpx;
		margin-top: 10rpx;
		color: #ffffff;
		font-size: 34rpx;
	}

	.w-box-title-header {
		font-size: 34rpx;
		color: #000000;
		font-weight: 700;
	}

	.w-box-title-dt {
		font-size: 28rpx;
		line-height: 34rpx;
	}

	.w-box-title-act {
		display: flex;
		justify-content: space-between;
	}

	.act-status {
		color: #E1B176
	}

	.act-cancel,
	.act-edit {
		position: absolute;
		color: #4497e1;
	}

	.act-cancel {
		right: 0;
	}

	.act-edit {
		right: 100rpx;
	}

	.w-box-title-org {
		position: absolute;
		margin-top: 16rpx;
		right: 0;
	}

	.w-box-row {
		font-size: 30rpx;
		line-height: 36rpx;
	}

	.w-box-row text {
		overflow: hidden;
		display: inline-block;
		text-overflow: ellipsis;
		white-space: nowrap;
		width: 670rpx;
	}

	.w-btns {
		background-color: #ffffff;
		padding: 20rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
	}

	.w-btns button {
		width: 710rpx;
		margin-left: 0;
	}
</style>
